package robotCross;

import abbot.tester.JTextComponentTester;
import operation.Operation;

import javax.swing.text.DefaultEditorKit;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * Created by hanyz on 2016/9/13.
 */
public class CrossJTextComponentTester extends JTextComponentTester {
    @Override
    public void actionEnterText(Component c, String text) {
        scrollToVisible(c, 0);
        actionActionMap(c, DefaultEditorKit.selectAllAction);
        if (!"".equals(getTextForComponent((JTextComponent)c))) {
            actionActionMap(c, DefaultEditorKit.deletePrevCharAction);
        }
        actionKeyString(c, text);
        Operation.robot.key(KeyEvent.VK_SHIFT);
    }
}
